<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" >

	<h:form id="frm3">
		<p:growl id="msgs1" showDetail="true" />
		<p:panel id="custPanel" header="物料基本信息维护"
			style="margin-bottom:5px">
			<h:panelGrid columns="8" cellspacing="10"  cellpadding="5">								
				<p:outputLabel value="物料编号" />
				<p:inputText  value="#{materialMB.io.id}" required="true" requiredMessage="物料编号必须输入"/>
				<p:outputLabel value="物料描述" />
				<p:inputText value="#{materialMB.io.mdesc}" required="true" requiredMessage="物料名称必须输入"/>
				<p:outputLabel value="规格" />
				<p:selectOneMenu value="#{materialMB.io.mmodel}"	style="width:80%;" editable="true">
					<f:selectItem  itemLabel="300*300"	itemValue="300*300" />
					<f:selectItem  itemLabel="450*300"	itemValue="450*300" />
					<f:selectItem  itemLabel="600*300"	itemValue="600*300" />
					<f:selectItem  itemLabel="600*600"	itemValue="600*600" />	
					<f:selectItem  itemLabel="800*800"	itemValue="800*800" />
					<f:selectItem  itemLabel="900*900"	itemValue="900*900" />
					<f:selectItem  itemLabel="600*900"	itemValue="600*900" />
					<f:selectItem  itemLabel="600*1200"	itemValue="600*1200" />
				</p:selectOneMenu>
				<p:outputLabel value="类别" />
				<p:selectOneMenu value="#{materialMB.io.msort}"	style="width:80%;" 
					required="true" requiredMessage="类别必须输入">
					<f:selectItem  itemLabel="瓷砖"	itemValue="1" />
					<f:selectItem  itemLabel="护栏"	itemValue="2" />
					<f:selectItem  itemLabel="材料"	itemValue="3" />
					<f:selectItem  itemLabel="加工"	itemValue="4" />	
					<f:selectItem  itemLabel="费用"	itemValue="5" />
				</p:selectOneMenu>

				<p:outputLabel value="自制/采购" />
				<p:selectOneMenu value="#{materialMB.io.mtype}"	style="width:120px;" 
					required="true" requiredMessage="加工方式必须输入">
					<f:selectItems value="#{materialMB.itemsMtype}" />
				</p:selectOneMenu>

				<p:outputLabel value="单位" />
				<p:inputText value="#{materialMB.io.munit}" />	
				<p:outputLabel value="采购价" />
				<p:inputText value="#{materialMB.io.purchPrice}" />	
				<p:outputLabel value="销售价" />
				<p:inputText value="#{materialMB.io.salePrice}" />	
				<p:outputLabel value="备注" />
				<p:inputText value="#{materialMB.io.remarks}" />	
					
			</h:panelGrid>
			<h:panelGrid columns="4" cellspacing="10">			
				<p:commandButton value="新增提交"	icon="ui-icon-check" 
					action="#{materialMB.addAction}" update=":tabview:frm3">
				</p:commandButton>	
				<p:commandButton value="查询"	icon="ui-icon-search"  immediate="true"
					action="#{materialMB.queryAction}" update=":tabview:frm3">
				</p:commandButton>	
			</h:panelGrid>
			<p:dataTable id="rdt" value="#{materialMB.vo}"  
				var="row"  rowIndexVar="rowNum"
				resizableColumns="true" liveResize="true" editable="true" 
				paginator="true" paginatorPosition="bottom" rows="8"
                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                rowsPerPageTemplate="5,10,15" emptyMessage="没有记录"                         
				style="margin-bottom:20px" >
				
				<p:ajax event="rowEdit" listener="#{materialMB.onRowEdit}"
					update=":tabview:frm3:msgs1" />
				<p:ajax event="rowEditCancel"	listener="#{materialMB.onRowCancel}"
					update=":tabview:frm3:msgs1" />
			
				<p:column headerText="No." style="width:5%">
					#{rowNum+1}
				</p:column>

				<p:column headerText="物料编号" sortBy="#{row.id}">
					<h:outputText id="modelInput" value="#{row.id}"	style="width:100%" />
				</p:column>
				<p:column headerText="物料描述" filterBy="#{row.mdesc}"	filterMatchMode="contains" >
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.mdesc}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.mdesc}" style="width:100%"
								label="物料描述" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="规格" >
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.mmodel}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.mmodel}" style="width:100%" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="物料类别">
					<p:cellEditor>
						<f:facet name="output">						
							<h:outputText value="#{row.msort == 1 ? '瓷砖' : (row.msort == 2 ? '护栏' : (row.msort == 3 ? '材料' : (row.msort == 4 ? '加工' : (row.msort == 5 ? '费用' : row.msort))))}" />						
						</f:facet>
						<f:facet name="input">
							<p:selectOneMenu value="#{row.msort}"	style="width:80%;" >
								<f:selectItems value="#{materialMB.itemsMsort}" var="vmsort" itemLabel="#{vmsort.label}" itemValue="#{vmsort.value}"/>
							</p:selectOneMenu>								
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="物料形式">
					<p:cellEditor>
						<f:facet name="output">
							<p:selectOneMenu value="#{row.mtype}" style="width:80%" disabled="true" >
								<f:selectItems value="#{materialMB.itemsMtype}" var="vmtype" itemLabel="#{vmtype.label}" itemValue="#{vmtype.value}"/>
							</p:selectOneMenu>	
						</f:facet>
						<f:facet name="input">
							<p:selectOneMenu value="#{row.mtype}" style="width:100%">
								<f:selectItems value="#{materialMB.itemsMtype}" var="vmtype" itemLabel="#{vmtype.label}" itemValue="#{vmtype.value}"/>
							</p:selectOneMenu>								
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="单位">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.munit}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.munit}" style="width:100%"
								label="单位" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="采购价格">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.purchPrice}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.purchPrice}" style="width:100%"
								label="采购价格" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="销售价格">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.salePrice}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.salePrice}" style="width:100%"
								label="销售价格" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="备注">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.remarks}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.remarks}" style="width:100%"
								label="备注" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column style="width:32px">
					<p:rowEditor />
				</p:column>
			</p:dataTable>

		</p:panel>
	</h:form>
				
</ui:composition>

